package di

import (
	"go.uber.org/dig"
	"sync"
)

var (
	defaultInject *inject

	syncOnce = &sync.Once{}
)

func InjectInstance() *inject {
	if defaultInject == nil {
		syncOnce.Do(func() {
			defaultInject = NewInject()
		})
	}

	return defaultInject
}

type inject struct {
	*dig.Container
}

func NewInject() *inject {
	c := dig.New()
	container := &inject{c}

	container.InjectRepo()

	container.InjectService()

	container.InjectServer()

	container.InjectController()
	return container
}
